<?php

/**
 * Class that can manage a mysql-db table structure
 *
 * @author		Ruben
 * @since		2 dec 2007
 */
class TableModel extends dbModel
{
	/**
	 * This method loads the table-structure of the asked source
	 *
	 */
	public function load ($iStart = 0, $iRows = 0)
	{
		$sSql = "DESCRIBE " . $this->sSource;
		
		//
		//query uitvoeren
		//
		$this->run_query($sSql);
		$this->oBench->start_mark();
		$this->iTotal = mysql_num_rows($this->rResult);
		$this->oBench->add_mark('counted rows');
		return $this->iTotal > 0;
	}
	
	
	/**
	 * Splits the field-type of a row into an array with 1 or 2 values (1 with a text-type).
	 * 	1 => fieldtype
	 *  2 => max-number of characters, or with an set type, all props that can be set
	 *
	 * @param unknown_type $sType
	 * @return unknown
	 */
	public static function extractType ($sType)
	{
		preg_match("#(\w+)\(([0-9', a-z]+)\)?#i", $sType, $aInput);
		array_shift($aInput);
		return $aInput;
	}
}

?>